package pageobjects;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

import java.util.List;

public class DocMangePo {
    public WebDriver driver;

    public DocMangePo(WebDriver driver) {
        this.driver = driver;
    }

    //新增文档按钮
    By newDocument = By.xpath("//button[@class='ui-btn ui-btn-primary ui-btn-middle ui-btn-inline ui-menu-select-btn-button']");
    //文档标题
    By title = By.xpath("//input[@class='ui-input' and @type='text' and @weid='xj9ztk_n9fsi1_ktapm0_93rio8_ayv4ho']");
    //文档内容所在的iframe
    By iframe = By.xpath("//iframe[@class='cke_wysiwyg_frame cke_reset']");
    //编写文档
    By content = By.xpath("//body[@class='cke__pc weapp-doc-rich-text-content cke_editable cke_editable_themed cke_contents_ltr']");
    //保存按钮
    By save = By.id("save");
    //关闭按钮
    By close = By.xpath("//div[@class='ui-dialog-icon ui-dialog-closeIcon']");
    //新增文档记录
    By NewAddedDoc = By.xpath("//div[@class='ui-list-body']/div[1]/div/div/div/div/div/div[@class='file-name']");

    //要删除的记录数据 ：目前总是删除第一条
    By DocToBeDelete = By.xpath("//div[@class='ui-list-body']/div[1]/div[@class='ui-list-content']");
    //文档详情，操作菜单
    By operation = By.xpath("//span[@class='weapp-doc-title-operate']");
    //操作菜单的 删除选项
    By remove = By.xpath("//div[@id='delete']/span[@class='ui-menu-list-item-content']");

    //确认删除按钮
    By confirm = By.xpath("//button[@weid='_ztj71q_swwb0l']");

    //这是所有目前存在的文档数据路径
    By deletedDocs =By.xpath("//div[@class='ui-list-item ui-list-item-noorder ui-list-unsortable']");


    /**
     * 新建文档
     *
     * @return
     */
    public WebElement newDocument() {
        return driver.findElement(newDocument);
    }

    /**
     * 文档标题
     *
     * @return
     */
    public WebElement title() {
        return driver.findElement(title);
    }

    //获取iframe路径
    public WebElement iframe() {
        return driver.findElement(iframe);
    }

    //编写文档
    public WebElement content() {

        return driver.findElement(content);
    }

    //保存文档
    public WebElement save() {
        return driver.findElement(save);
    }

    //关闭文档
    public WebElement close() {
        return driver.findElement(close);
    }

    //获取到文档列表第一条数据的名称
    public WebElement NewAddedDoc() {
        return driver.findElement(NewAddedDoc);
    }

    //点击要删除的文档数据
    public WebElement DocToBeDelete() {
        return driver.findElement(DocToBeDelete);
    }

    //文档详细 点击操作
    public WebElement Operation() {
        return driver.findElement(operation);
    }

    //操作菜单的删除按钮
    public WebElement Remove() {
        return driver.findElement(remove);
    }

    //确认删除按钮
    public WebElement Confirm() {
        return driver.findElement(confirm);
    }
    //被删除的特定文档记录集合
    public List<WebElement> deletedDocs(){
        return driver.findElements(deletedDocs);
    }

}
